import {
	setStore,
	getStore,
	removeStore
} from '@/util/store'
import website from '@/config/website'

const common = {

	state: {
		language: getStore({
			name: 'language'
		}) || 'zh',
		isCollapse: false,
		isFullScren: false,
		isMenu: true,
		isShade: false,
		screen: -1,
		isLock: getStore({
			name: 'isLock'
		}) || false,
		showTag: false,
		showDebug: false,
		showCollapse: true,
		showSearch: false,
		showLock: false,
		showFullScren: false,
		showTheme: false,
		showMenu: true,
		showColor: false,
		colorName: getStore({
			name: 'colorName'
		}) || '#409EFF',
		themeName: 'theme-white',
		lockPasswd: getStore({
			name: 'lockPasswd'
		}) || '',
		website: website,
		screenWidth:1920, //   屏幕
		materialNumberType: 0, // 原材料编号
		batchNumberType: 0, //  生产批号
		versionNumberType: 0, //   文件版本号
		serialNumberType: 0, //   流水编号类型
		sterilizeNumberType: 0, // 灭菌编号类型
		numberType: 0 //  编号类型
	},
	mutations: {
		SET_SCREENWIDTH: (state, width)=> {
			console.log('width......'+width)
			state.screenWidth = width;
		},
		SET_MATERIALNUMBERTYPE: (state, type) => {
			state.materialNumberType = type;
		},
		SET_BATCHNUMBERTYPE: (state, type) => {
			state.batchNumberType = type;
		},
		SET_VERSIONNUMBERTYPE: (state, type) => {
			state.versionNumberType = type;
		},
		SET_SERIALNUMBERTYPE: (state, type) => {
			state.serialNumberType = type;
		},
		SET_STERILIZENUMBERTYPE: (state, type) => {
			state.sterilizeNumberType = type;
		},
		SET_NUMBERTYPE: (state, type) => {
			state.numberType = type;
		},
		SET_LANGUAGE: (state, language) => {
			state.language = language
			setStore({
				name: 'language',
				content: state.language
			})
		},
		SET_SHADE: (state, active) => {
			state.isShade = active;
		},
		setdeptOption: (state, active) => {
			state.deptOption = active;
		},
		SET_COLLAPSE: (state) => {
			state.isCollapse = !state.isCollapse;
		},
		SET_FULLSCREN: (state) => {
			state.isFullScren = !state.isFullScren;
		},
		SET_IS_MENU: (state, menu) => {
			state.isMenu = menu;
		},
		SET_LOCK: (state) => {
			state.isLock = true;
			setStore({
				name: 'isLock',
				content: state.isLock,
				type: 'session'
			})
		},
		SET_SCREEN: (state, screen) => {
			state.screen = screen;
		},
		SET_COLOR_NAME: (state, colorName) => {
			state.colorName = colorName;
			setStore({
				name: 'colorName',
				content: state.colorName,
			})
		},
		SET_THEME_NAME: (state, themeName) => {
			state.themeName = themeName;
			setStore({
				name: 'themeName',
				content: state.themeName,
			})
		},
		SET_LOCK_PASSWD: (state, lockPasswd) => {
			state.lockPasswd = lockPasswd;
			setStore({
				name: 'lockPasswd',
				content: state.lockPasswd,
				type: 'session'
			})
		},
		CLEAR_LOCK: (state) => {
			state.isLock = false;
			state.lockPasswd = '';
			removeStore({
				name: 'lockPasswd',
				type: 'session'
			});
			removeStore({
				name: 'isLock',
				type: 'session'
			});
		},
	}
}
export default common
